/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.tfile;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * <p>Project: jse2303 - FileClient</p>
 * <p>Powered by webrx On 2023-07-26 14:04:37</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Fclient {
    public static void main(String[] args) {

        try {
            Socket c = new Socket("192.168.21.6", 8888);
            //发文件
            String file = "c.jpg";
            String ext = file.substring(file.lastIndexOf(".") + 1);
            InputStream is = new FileInputStream(file);

            OutputStream os = c.getOutputStream();
            os.write(ext.getBytes());

            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = is.read(buf)) > 0) {
                os.write(buf, 0, len);
            }

        } catch (Exception e) {

        }
    }
}
